package com.WFinstitute.serviceImpl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.WFinstitute.domain.News;
import com.WFinstitute.repository.NewsRepository;
import com.WFinstitute.service.NewsService;
import com.WFinstitute.util.Page;

@Service
public class NewsServiceImpl implements NewsService{
	@Resource
	private NewsRepository  newsRepository;

	@Override
	public News addNews(News news) {
		return newsRepository.save(news);
	}

	@Override
	public Page<News> findNewsList(Integer pageSize, Integer pageIndex,String name) {
		String jpql="select n from News n order by n.createtime desc";
		return newsRepository.getAllPage(jpql, null, pageSize, pageIndex);
	}

	@Override
	public long count() {
		return newsRepository.count();
	}

	@Override
	public News updateNews(News news) {
		 return (News)newsRepository.update(news);
	}

	@Override
	public News findNewsById(Integer id) {
		return newsRepository.findOne(id);
	}



}
